﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>发布评论</title>
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
    <link href="https://cdn.bootcss.com/amazeui/2.7.2/css/amazeui.css" rel="stylesheet">
    <link rel="stylesheet" href="lib/jquery.raty.css">
    <style>
        body {
            background: #f4f5f9;
            font-family: 微软雅黑;
        }

        .main {
            width: 100%;
        }

        .coachassess {
            padding: 0 2%;
            width: 100%;
            background: #fff;
            margin-bottom: 3%;
        }

        .coachassess-head {
            display: flex;
            padding: 4% 0;
            align-items: center;
            border-bottom: 1px solid #cbcbcb;
        }

        #star01 img, #star02 img {
            width: 10%;
        }

        textarea {
            width: 100%;
            border: none;
            padding: 2%;
            resize: none;
        }
    </style>
</head>
<body>
    <div id="page">
        <!--<div id="star"  data-score="4.5" ></div>-->
        <header data-am-widget="header" class="am-header am-header-default" style="background-color: #FFFFFF; border-bottom: 1px solid rgb(211, 211, 211);">
            <div class="am-header-left am-header-nav" onclick="goBack()">
                <a href="javascript:" class="">
                    <img class="am-header-icon-custom" src="images/veas07.png" alt="" />
                </a>
            </div>
            <h4 class="am-header-title" style=" color: black;">发布评论</h4>
            <div class="am-header-right am-header-nav"><a href="/Wap/Index.html" class="am-header-icon am-icon-home" style="color: #A9A9A9; "></a></div>
        </header>
        <div class="main">
            <div class="coachassess">
                <div class="coachassess-head">
                    <div>教练评价</div>
                    <div id="star01" v-bind:data-score="coachscroe" style=" margin-left: 5%; margin-top: -1%;"></div>
                    <div id="targetType-hint01" class="hint" style="opacity: 0"></div>
                </div>
                <textarea class="" rows="6" v-model="jiaolian" placeholder="你想说点什么？"></textarea>
            </div>
            <div class="coachassess">
                <div class="coachassess-head">
                    <div>平台评价</div>
                    <div id="star02" v-bind:data-score="platformscroe" style=" margin-left: 5%; margin-top: -1%;"></div>
                    <div id="targetType-hint02" class="hint" style="opacity: 0"></div>
                </div>
                <textarea class="" rows="6" v-model="pingtai" placeholder="你想说点什么？"></textarea>
            </div>
        </div>
        <button class="am-btn" v-on:click="tijiao()" style="background: #6fddb1;color: #fff;width: 100%;position: fixed;bottom: 0;padding: 3% 0">评价</button>
    </div>
</body>
<script src="https://cdn.bootcss.com/jquery/1.8.3/jquery.js"></script>
<script src="lib/jquery.raty.js"></script>
<script src="https://cdn.bootcss.com/vue/2.5.9/vue.js"></script>
<script src="https://cdn.bootcss.com/amazeui/2.7.2/js/amazeui.js"></script>
<script src="js/common.js"></script>
<script>
    var page = new Vue({
        el: '#page',
        data: {
            te:{},
            coachscroe: 5,
            platformscroe: 5,
            jiaolian: "",
            pingtai: ""
        },
        methods: {
            getInfo: function () {
                var that = this;
                $.ajax({
                    type: 'POST',
                    url: window.apiUrl + '/Api/Field/GetTrainEvaluate',
                    data: { "gId": $.getParam("gId") },
                    success: function (data) {
                        if (data.errcode == 0) {
                            that.te = data.data.te;
                            if (that.te.length >= 2)
                            {
                                console.log(that.te);
                                if(that.te[0].Type==1)//平台
                                {
                                    that.platformscroe = that.te[0].Score;
                                    that.pingtai = that.te[0].Info;
                                    console.log(that.platformscroe);
                                }
                                else
                                {
                                    that.coachscroe = that.te[0].Score;
                                    that.jiaolian = that.te[0].Info;
                                }
                                if (that.te[1].Type == 1)//平台
                                {
                                    that.platformscroe = that.te[1].Score;
                                    that.pingtai = that.te[1].Info;
                                    console.log(that.platformscroe);
                                }
                                else {
                                    that.coachscroe = that.te[1].Score;
                                    that.jiaolian = that.te[1].Info;
                                }
                            }
                        }
                    }
                });
            },
            tijiao: function () {
                var that = this;
                //alert($.getParam("gId"));
                $.ajax({
                    type: 'POST',
                    url: window.apiUrl + '/Api/Field/AddTrainEvaluate',
                    data: { score1: that.coachscroe, score2: that.platformscroe, jiaolian: that.jiaolian, pingtai: that.pingtai, gId: $.getParam("gId") },
                    success: function (data) {
                        console.log(data);
                        if (data.errcode == 0) {
                            alert(data.errmsg, function () {
                                if (data.data.typeid == 1)
                                {
                                    location.href = "TrainUserDetails.html?gId=" + data.data.signgId;
                                }
                                else
                                {
                                    location.href = "TrainCardUserDetails.html?gId=" + data.data.signgId;
                                }
                            });
                        } else {
                            alert(data.errmsg);
                        }
                    },
                })
            }
        },
    })
    $(function () {
        $("#star01").raty({
            starOn: 'lib/images/star-on.png',
            starOff: 'lib/images/star-off.png',
            readOnly: false,
            halfShow: false,
            half: false,
            size: 34,
            target: '#targetType-hint01',
            targetType: 'number'
        });
        $("#star02").raty({
            half: false,
            starOn: 'lib/images/star-on.png',
            starOff: 'lib/images/star-off.png',
            readOnly: false,
            halfShow: false,
            size: 34,
            target: '#targetType-hint02',
            targetType: 'number'
        });
        $("#star01").click(function () {
            page.coachscroe = $(this).next().html();
        });
        $("#star02").click(function () {
            page.platformscroe = $(this).next().html()
        })
        page.getInfo();
    });
</script>
<script>

</script>
</html>
